function [ obj ] = evaluate_noise_latency(weight, idx, relevant_idx, target_hover_state, H, dt, model)
%UNTITLED4 Summary of this function goes here
%   Detailed explanation goes here
basin = 15;
start_ned = 0*rand(3,1) - 0*ones(3,1);
rotation_axis = normc(randn(3,1));
rotation_angle = 0*2*pi*rand(); % radians
start_q = [sin(rotation_angle/2)*rotation_axis; cos(rotation_angle/2)];
basin = 15;

start_state = target_hover_state;
start_state(idx.ned) = start_ned;
start_state(idx.q) = start_q;
latency = 1;
for i=1:latency+1
	x(:,i) = start_state;
end

cost = 0;
for t=latency+1:H   
    delta_u = policy1(weight, x(:,t-latency), target_hover_state, idx);
    %cost = cost + dt*([1 1 1]*((x(idx.ned,t) - target_hover_state(idx.ned)).^2) + [0.1 0.1 0.1]*(x(idx.ned_dot,t).^2) + 0.1*[1 1 1 1]*delta_u.^2);
    noise_F_T = 1*randn(6,1);
    x(:,t+1) = f_heli(x(:,t), delta_u, dt, model, idx, noise_F_T);
    if(norm(x(idx.ned,t+1) - target_hover_state(idx.ned,:)) > basin)
        %cost = cost + 1000*(H-t);
        break;
    end
end


obj = t;

end

